import java.util.Vector;


public class ServerCommand {
	
	private String name;
	private Vector<CommandParameter> values;
	
	public ServerCommand() {
		name = null;
		values = new Vector<CommandParameter>();
	}
	
	//ADDED CONSTRUCTOR! some commands doesn't need any parameters, just name
	public ServerCommand(String name) { 
		this.name = name;
		values = new Vector<CommandParameter>(); //mandatory or not ? 
	}
	
	public ServerCommand(String name, CommandParameter cp) {
		this.name = name;
		this.values = new Vector<CommandParameter>();
		this.values.addElement(cp);
	}
	
	public ServerCommand(String name, Vector<CommandParameter> cps) {
		this.name = name;
		this.values = new Vector<CommandParameter>();
		for(Integer i = 0; i < cps.size(); i++) {
			this.values.addElement(cps.elementAt(i));
		}
	}
	
	public Integer commandParameterCount() {
		return values.size();
	}
	
	public void addCommandParameter(CommandParameter cp) {
		this.values.addElement(cp);
	}
	
	public CommandParameter getCommandParameter(Integer i) {
		return values.elementAt(i);
	}
	
	//Broken
	public Integer getValueOfParameter(String paramName) {
		for(Integer i = 0; i < this.values.size(); i++) {
			if(this.values.elementAt(i).getName().equals(paramName)) {
				return this.values.elementAt(i).getValue();
			}
		}
		return 0;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void SetName(String name) {
		this.name = name;
	}
	
	public boolean isMove() {
		if(name.equals("move"))
			return true;
		else
			return false;
	}	
	
	public boolean isRotate() {
		if(name.equals("rotate"))
			return true;
		else
			return false;
	}
	
	public boolean isScan() {
		if(name.equals("scan"))
			return true;
		else
			return false;
	}
	
	public boolean isReboot() {
		if(name.equals("reboot"))
			return true;
		else
			return false;
	}
	
	public boolean isClose() {
		if(name.equals("G2close"))
			return true;
		else
			return false;
	}
	
	public boolean isMoveForward() { //added
		if(name.equals("G2moveForward"))
			return true;
		else
			return false;
	}
	
	public boolean isMoveBackward() {
		if(name.equals("G2moveBackward"))
			return true;
		else
			return false;
	}
	
	public boolean isStop() {
		if(name.equals("G2stop"))
			return true;
		else
			return false;
	}
	
	public boolean isAutoMode() {
		if(name.equals("G2autoMode"))
			return true;
		else
			return false;
	}
	
	public boolean isMapRequest() {
		if(name.equals("G2mapRequest"))
			return true;
		else
			return false;
	}
	
}
